﻿<?php
@session_start();
require_once('./inc/global.php');

if( empty($_SESSION['AID']) ){
	echo '<script type="text/javascript">document.location.href="./login.php";</script>';
	exit;
}

$str = file_get_contents('./image2/cache/menu_cache.php');

$str_2 = file_get_contents('./image2/cache/menu_cache_2.php');
$menu = unserialize( $str );
$menu_2 = unserialize( $str_2 );

$menu_num = count( $menu );
$menu_list_num = 9;

$queue_sum = queueSum();//是否有自己的队列

$test_sum = testTaskManageSum();//是否有测试任务
$pub_sum = pubTaskManageSum();//是否有发布任务


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="off">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>海外营销CMS系统后台管理中心【万兴软件】</title>
<link rel="stylesheet" type="text/css" href="./bg/frame/css/reset.css" />
<link rel="stylesheet" type="text/css" href="./bg/frame/css/system.css" />
<link rel="stylesheet" type="text/css" href="./bg/frame/css/dialog.css" />
<link rel="stylesheet" type="text/css" href="./bg/frame/css/style/styles1.css" title="styles1" media="screen" />
<link rel="alternate stylesheet" type="text/css" href="./bg/frame/css/style/styles2.css" title="styles2" media="screen" />
<link rel="alternate stylesheet" type="text/css" href="./bg/frame/css/style/styles3.css" title="styles3" media="screen" />
<link rel="alternate stylesheet" type="text/css" href="./bg/frame/css/style/styles4.css" title="styles4" media="screen" />
<script language="javascript" type="text/javascript" src="./bg/frame/js/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="./bg/frame/js/styleswitch.js"></script>
<script language="javascript" type="text/javascript" src="./bg/frame/js/dialog.js"></script>
</head>
<body scroll="no">
<div id="dvLockScreen" class="ScreenLock" style="display:none">
    <div id="dvLockScreenWin" class="inputpwd">
    <h5><b class="ico ico-info"></b><span id="lock_tips">锁屏状态，请输入密码解锁</span></h5>
    <div class="input">
    	<label class="lb">密码：</label><input type="password" id="lock_password" class="input-text" size="24">
        <input type="submit" class="submit" value="&nbsp;" name="dosubmit" onclick="check_screenlock();return false;">
    </div></div>
</div>

<div class="header">
	<div class="logo lf"><a href="" target="_blank"><span class="invisible">海外营销CMS系统后台管理中心</span></a></div>
    <div class="rt">
    	<div class="tab_style white cut_line text-r">
            <?php if( !empty($menu_2[2]) ){foreach( $menu_2[2] as $v ){?>
        	<a href="javascript:_M(-1,'<?php echo $v['MUrl'];?>')">[<?php echo $v['Menu_name'];?>]</a><span>|</span>
        <?php }}?>
        <a href="javascript:;" onclick="lock_screen()"><img src="./bg/frame/images/lockscreen.png"> 锁屏</a>
    <ul id="Skin">
		<li class="s1 styleswitch" rel="styles1"></li>
		<li class="s2 styleswitch" rel="styles2"></li>
		<li class="s3 styleswitch" rel="styles3"></li>
        <li class="s4 styleswitch" rel="styles4"></li>
	</ul>
        </div>
        <div class="style_but"></div>
    </div>
    <div class="col-auto" style="overflow: visible">
    	<div class="log white cut_line">您好！<?php echo $_SESSION['AName'];?>
        	<span>|</span><a href="javascript:_M(-1,'./login.php?action=logout')">[注销退出]</a>
            <span>|</span><a href="javascript:_M(-1,'./cpw.php')">[修改密码]</a>
        <span style="color:red; font-weight:bold; margin-left:30px;">预CMS</span>
        
        <?php 
        	if ($queue_sum > 0) {//是否有自己的队列
         ?>
	         <a href="javascript:_M(-1, './wondershare/task_queue.php?action=index')"><span style="color:#FF0; font-weight:bold; margin-left:10px;">我的队列(<?php echo $queue_sum;?>)个记录</span></a>
	         <a href="javascript:void(0);" onclick="deleteQueue()"><span style="color:#FF0; font-weight:bold; margin-left:10px;">清除队列</span></a>
		<?php } 
			if ($test_sum > 0) {//是否有自己的测试任务
		?> 
			<a href="javascript:_M(-1, './wondershare/task_manage.php?action=index&type=test')"><span style="color:red; font-weight:bold; margin-left:10px;">你有(<?php echo $test_sum;?>)个测试任务</span></a>
	        
		<?php } 
			if ($pub_sum > 0) {//是否有自己的发布任务
		?> 
			<a href="javascript:_M(-1, './wondershare/task_manage.php?action=index&type=pub')"><span style="color:red; font-weight:bold; margin-left:10px;">你有(<?php echo $pub_sum;?>)个发布任务</span></a>
		<?php } ?> 
    	</div>
        <ul class="nav white" id="top_menu">
			<li id="_M3" class="on top_menu"><a href="javascript:_M(3,'')" hidefocus="true" style="outline:none;">Home</a></li>
            <li id="_M4" class="top_menu"><a href="javascript:_M(4,'')" hidefocus="true" style="outline:none;">WS.COM.BR</a></li>
        </ul>
    </div>
</div>

<div id="content">
	<div class="col-left left_menu">
    	<div id="leftMain"></div>
        <a href="javascript:;" id="openClose" style="outline-style:none;outline-color:invert;outline-width:medium;" hideFocus="hidefocus" class="open" title="展开与关闭"><span class="hidden">展开</span></a>
    </div>
	<div class="col-1 lf cat-menu" id="display_center_id" style="display:none" height="100%">
		<div class="content">
        	<iframe name="center_frame" id="center_frame" src="" frameborder="false" scrolling="auto" style="border:none" width="100%" height="auto" allowtransparency="true"></iframe>
        </div>
    </div>
    <div class="col-auto mr8">
    <div class="crumbs">
    <div class="shortcut cu-span" id="right_nav">
<!--    	<a href="?m=content&c=create_html&a=public_index&pc_hash=e2915V" target="right"><span>生成首页</span></a>
        <a href="?m=admin&c=cache_all&a=init&pc_hash=e2915V" target="right"><span>更新缓存</span></a>-->
    </div>
    当前位置：<span id="current_pos">Home</span></div>
    	<div class="col-1">
        	<div class="content" style="position:relative; overflow:hidden">
                <iframe name="right" id="rightMain" src="" frameborder="false" scrolling="auto" style="border:none;margin-bottom:30px;" width="100%" height="auto" allowtransparency="true"></iframe>
                <div class="fav-nav">
					<div id="panellist">
                    	<span><a href="javascript:void(0);">系统通知</a></span>
					</div>
					<div id="paneladd">
                    	<div style="margin-left:10px;">
                    		<span id="sys_notice_1" style="display:inline;float:none;padding:0px 10px 0px 3px;color:red;display:none;font-weight:bold;cursor:pointer;" href="javascript:void(0);" target="right">点击查看</span>
                            <span id="sys_notice_2" style="display:inline;float:none;padding:0px 10px 0px 3px;color:green;display:none;font-weight:bold;cursor:pointer;" href="javascript:void(0);" target="right">点击查看</span>
                    	</div>
                     </div>
                    <div id="help" class="fav-help"></div>
				</div>
        	</div>
        </div>
    </div>
</div>

<ul class="tab-web-panel hidden" style="position:absolute; z-index:999; background:#fff;" id="tab-web-panel">
<?php 
foreach( $menu as $v ){
	if( $_SESSION['AID'] != 1 && !in_array( $v['mid'], $mpower ) ) continue;
?>
	<li style="margin:0"><a href="javascript:_M(<?php echo $v['mid'];?>,'')"><?php echo $v['name'];?></a></li>
<?php }?>
</ul>
 
<script type="text/javascript">

$(function(){
	windowW();
	
	$(".switchs").each(function(i){
		var ul = $(this).parent().next();
		$(this).click(function(){
			if(ul.is(':visible')){
				ul.hide();
				$(this).removeClass('on');
			}else{
				ul.show();
				$(this).addClass('on');
			}
		})
	});
	
	$("#leftMain").load("./bg/menu.php?mid=<?php echo $default_mid;?>");
	
	//隐藏more菜单
	$("body").click(function(){$("#tab-web-panel").hide()});
	$("#rightMain").click(function(){$("#tab-web-panel").hide()});
})
//clientHeight-0; 空白值 iframe自适应高度
function windowW(){
	if($(window).width()<980){
		$('.header').css('width',980+'px');
		$('#content').css('width',980+'px');
		$('body').attr('scroll','');
		$('body').css('overflow','');
	}
}

$(window).resize(function(){
	if($(window).width()<980){
		windowW();
	}else{
		$('.header').css('width','auto');
		$('#content').css('width','auto');
		$('body').attr('scroll','no');
		$('body').css('overflow','hidden');		
	}
});

window.onresize = function(){
	var heights = document.documentElement.clientHeight-150;
	document.getElementById('rightMain').height = heights;
	var openClose = $("#rightMain").height()+39;
	$('#center_frame').height(openClose+9);
	$("#openClose").height(openClose+30);	
}
window.onresize();

//站点下拉菜单
$(function(){
	var offset = $(".tab_web").offset();
	$(".tab_web").mouseover(function(){
		$(".tab-web-panel").css({ "left": +offset.left+4, "top": +offset.top+$('.tab_web').height()});
		$(".tab-web-panel").show();
	});
	
	$(".tab_web").mouseout(function(){
		$("#tab-web-panel").hide();
	});
	
	$("#tab-web-panel").mouseover(function(){
		$("#tab-web-panel").show();
	});
	
	$("#tab-web-panel").mouseout(function(){
		$("#tab-web-panel").hide();
	});
	
	//$(".tab_web span").mouseout(function(){hidden_site_list_1()});
	//$(".tab-web-panel").mouseover(function(){clearh();$('.tab_web a').addClass('on')}).mouseout(function(){hidden_site_list_1();$('.tab_web a').removeClass('on')});

})

//切换头部菜单
function _M(menuid,targetUrl) {
	$("#menuid").val(menuid);
	$("#bigid").val(menuid);
	//$("#paneladd").html('<a class="panel-add" href="javascript:add_panel();"><em>添加</em></a>');

	if( menuid != -1 ){
		$("#leftMain").load('./bg/menu.php?mid='+menuid);
	}else{
		$("#rightMain").attr('src', targetUrl);
	}
	
	$('.top_menu').removeClass("on");
	$('#_M'+menuid).addClass("on");
	
	//当点击顶部菜单后，隐藏中间的框架
	$('#display_center_id').css('display','none');
	//显示左侧菜单，当点击顶部时，展开左侧
	$(".left_menu").removeClass("left_menu_on");
	$("#openClose").removeClass("close");
	$("html").removeClass("on");
	$("#openClose").data('clicknum', 0);
	$("#current_pos").data('clicknum', 1);
	
	
	synDisqus( menuid );

	productReview( menuid );

}

//取得站点未生成的disqus评论
function synDisqus( menuid ){
	$.get('./disqus/syn_comment.php?m=get_new&sid='+menuid,function(data){
		if( data > 0 ){
			$("#sys_notice_1").html( '该站点有【'+data+'】条新评论未生成至文章');
			$("#sys_notice_1").click(function(){
				$("#rightMain").attr('src', 'disqus/list_comment.php?m=create&sid='+menuid);
			});
			$("#sys_notice_1").show();
		}else{
			$("#sys_notice_1").hide();
		}
	});
}

//生成disqus评论至文章成功，子框架中调用（sys_comment.php）
function synDisqusOk( menuid ){
	alert('评论生成至文章成功！');
	synDisqus( menuid );
}


//取得站点产品评论信息
function productReview( menuid ){
	$.get('./wondershare/product_review.php?action=wait_check&menuid='+menuid,function(data){
		if( data > 0 ){
			$("#sys_notice_2").html( '该站点有【'+data+'】条新产品评论等待审核');
			$("#sys_notice_2").click(function(){
				$("#rightMain").attr('src', 'wondershare/product_review.php?action=index&menuid='+menuid);
			});
			$("#sys_notice_2").show();
		}else{
			$("#sys_notice_2").hide();
		}
	});
}


function _MP(mid,menuid,targetUrl) {
	$("#menuid").val(menuid);
	//$("#paneladd").html('<a class="panel-add" href="javascript:add_panel();"><em>添加</em></a>');

	$("#rightMain").attr('src', targetUrl);

	$('.sub_menu').removeClass("on fb blue");
	$('#_MP'+menuid).addClass("on fb blue");

	var nav_1 = $("#_M"+mid+" a").html();
	var nav_2 = $("#_MP"+menuid).parent("ul").prev("h3").html();
	var nav_3 = $("#_MP"+menuid+" a").html();
	$("#current_pos").html( nav_1 ? nav_1 : 'More' +" > " +nav_2 + " > " +nav_3 );
	
	//$("#current_pos").data('clicknum', 1);
	//右侧导航
	$("#right_nav").html("")
}

//左侧开关
$("#openClose").click(function(){
	if($(this).data('clicknum')==1) {
		$("html").removeClass("on");
		$(".left_menu").removeClass("left_menu_on");
		$(this).removeClass("close");
		$(this).data('clicknum', 0);
	} else {
		$(".left_menu").addClass("left_menu_on");
		$(this).addClass("close");
		$("html").addClass("on");
		$(this).data('clicknum', 1);
	}
	return false;
});

//note 添加快捷方式面板
function add_panel() {
	var menuid = $("#menuid").val();
	$.ajax({
		type: "POST",
		url: "?m=admin&c=index&a=public_ajax_add_panel",
		data: "menuid=" + menuid,
		success: function(data){
			if(data) {
				$("#panellist").html(data);
			}
		}
	});
}
//note 删除快捷方式面板
function delete_panel(menuid, id) {
	$.ajax({
		type: "POST",
		url: "?m=admin&c=index&a=public_ajax_delete_panel",
		data: "menuid=" + menuid,
		success: function(data){
			$("#panellist").html(data);
		}
	});
}


function paneladdclass(id) {
	$("#panellist span a[class='on']").removeClass();
	$(id).addClass('on')
}

//note 判断是否锁屏
$(function(){
	$.get("./bg/ajax.php?m=is_lock",function(data){
		if( data == 'yes' ){
			$('#dvLockScreen').css('display','');
		}	
	});
})

//note 锁屏
function lock_screen() {
	$.get("./bg/ajax.php?m=lock");
	$('#dvLockScreen').css('display','');
}

//note 解锁
function check_screenlock() {
	var lock_password = $('#lock_password').val();
	if(lock_password=='') {
		$('#lock_tips').html('<font color="red">密码不能为空。</font>');
		return false;
	}
	$.get("./bg/ajax.php?m=open_lock", {lock_password: lock_password},function(data){
		if( data.substr(0,3) == 'err'){
			$('#lock_password').val('');
			strings = data.split('|');
			$('#lock_tips').html('<font color="red">密码错误，您还有'+strings[1]+'次尝试机会！</font>');
		}else if( data == 'exit' ){
			alert("您尝试输入的三次密码错误，系统自动退出！");
			document.location.href="./login.php?action=logout";
		}else{
			$('#lock_tips').html('锁屏状态，请输入密码解锁')
			$('#lock_password').val('');
			$('#dvLockScreen').css('display','none');	
		}	
	});
}

//清除我的队列
function deleteQueue() {
	
	$.ajax({
		async:false, 
		url:'/wondershare/task_queue.php?action=delete', 
		data:{type:'delAll'}, 
		success:function(data)
		{
			alert(data);
			
		}
	});
}

//$(document).bind('keydown', 'return', function(evt){check_screenlock();return false;});
</script>
</body>
</html>